<?php
/**
 * Template Name: Portfolio style 2
 * The main template file for display portfolio page.
 * Author : vthanh_88
 * @package WordPress
*/
get_header();
wp_enqueue_script('filterable');	
#
#Get Paged
#
if ( get_query_var('paged') ) {
	$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) { 
	$paged = get_query_var('page');
} else {
	$paged = 1;
}
$posts_per_page = get_theme_option('blog','blog_post_per_page');

$args = array(
	'post_type' => 'portfolio',
	'posts_per_page' => $posts_per_page,
	'paged' => $paged 
);
if(is_page())
{
    
	query_posts($args);
}else{
	global $wp_query;
	$query_args = array_merge( $wp_query->query, $args );
	global $posts;
	$posts=query_posts($query_args);
}
	
if(have_posts()):
?>
  	
     <div class="wrapper">
        <?php get_sidebar(); ?>		 
        <div class="right-panel-outer">
			<div class="right-panel">
			   <div class="right-inner">
                    <h2 class="head"><?php the_title(); ?></h2>
        	   </div>	
			   <?php 
			   
			   if(is_page())
                {
                	query_posts($args);
                }else{
                	global $wp_query;
                	$query_args = array_merge( $wp_query->query, $args );
                	global $posts;
                	$posts=query_posts($query_args);
                }
				$content = get_the_content();
			   ?>	
			   <?php rewind_posts(); ?>  
               <?php include_once('loop/loop-portfolio-2.php'); ?>
			   <?php echo do_shortcode($content);?>
    	    </div>
			<div class="content-shadow">&nbsp;</div>
        </div>
        <div class="clearfix"></div>
    </div>
<?php
else:
?>
    <div class="wrapper">
        <?php get_sidebar(); ?>		 
        <div class="right-panel-outer">
			<div class="right-panel">
			   <div class="right-inner">
                   <h2 class="head"><?php echo 'NOT FOUND PAGE'; ?></h2>			
               </div>
			  <div class="right-inner">
			  	   <p> NOT FOUND PAGES</p>
			  </div>
    	    </div>
			<div class="content-shadow">&nbsp;</div>
        </div>
        <div class="clearfix"></div>
    </div>
<?php
endif;
get_footer();
?>